Introduction to How JavaScript Works?
July 4, 2021 posted by Junior Kian Chong
Introduction to How JavaScript Works?
JavaScript is a scripting language that is used within the browser for interface interaction. Brendan Eich was the first person to create JavaScript engine was for the Netspace Navigator web browser at Netspace. It is implemented in C and its code name was SpiderMonkey. Mocha was the name given to the project initially, then renamed to LiveScript and finally when Netspace and Sun did license agreement it was again renamed to JavaScript. In this topic, we are going to learn about how javascript works. We must have heard about popular engines like V8, Spider Monkey and there are many others. Different engines have different “codenames”, for example:
- V8 – engine used in Opera & Chrome.
- SpiderMonkey – engine used in Firefox.
- Trident, Chakra – engine used in IE & Nitro.
- ChakraCore – engine used in Microsoft Edge.
- SquirrelFish – engine used in Safari.
The engine used for javascript consists of two main components:
- Heap Memory— this is where the allocation of memory happens.
- Call Stack — this is the place where the stacks are getting called and the code executes.
NOTE:
JavaScript, a single-threaded programming language, which means it has a single Call Stack and thus it has the ability to do one thing at a time. The Call Stack is basically a data structure which records the point in the program which is actually executing. This call stack is similar to other stack having the basic functionality like, if we step into a function, we put it on the top of the stack. We have to pop off the top of the stack if we want to return from a function. This is the basic functionality of every stack. As we are discussing the engines which drive the JavaScript functions are really complicated but the basic things which every engine performs in the broader sense are as follows:
- If the browser reads the script then the engine is embedded in the browser itself.
- After reading the script it converts (“compiles”) the script to the machine language.
- And then the machine code runs, pretty fast.
What can in-browser JavaScript works do?
- It changes the existing content, modifies styles by adding new HTML to the pages.
- Provides functions like a mouse click, mouse hover, etc. which reacts to the actions of the use.
- Send and Receive requests over the network to remote servers, without loading the complete page as the user inputs. One such technology which is very famous is AJAX.
- With this one can set and get the values of cookies, provides messages to the users for information, alert and other purposes.
- Also can store temporary data on client side.
What CAN’T in-browser JavaScript works do?
JavaScript’s abilities are somewhat limited within the browser are limited for the sake of the user’s safety. The aim is to prevent some third party webpage from accessing private information or harming the user’s data. Some scenarios for this kind of limited access are:
What makes JavaScript work unique?
Limitations
Among the many advantages JavaScript has some limitations also which are given below:
Conclusion
So with that, we all came to know that about some basic information about the evolutions of JavaScript works, some of the famous engines which run JavaScript on web browsers, what are the advantages of keeping JavaScript inside the browsers and what could happen if JavaScript could be placed and run outside the browsers. We have also come across some of the features of JavaScript work which made it usable and unique along with some of the limitation/disadvantage of it. So with that, I am concluding the topic on how javascript work, there are many more things to explore which you could explore from the web.
Coding . JavaScript